from api.ihrm_department_api import IHRMDEPARTMENT
from common.token_util import TOKENUTIL



class DEP_ID:
    @classmethod
    def get_department_id(cls):
        token=TOKENUTIL.get_token()
        # 引用已经提取了登录令牌token的包直接定义token变量接收
        body={"name":"猪猪部门","code":"9999"}
        resp=IHRMDEPARTMENT.department_add(token,body)
        # 调用添加部门的方法传上token和body就可以得到添加部门的结果
        # print(resp.json())
        dep_id=resp.json().get("data").get("id")
        # 用变量dep_id接收，提取响应结果里面的id

        return  dep_id
       # 记得把提取的id要return返回，调用时候才可以看到id
       #  封装接口一定要return返回，调用时候才可以看到结果

if __name__ == '__main__':
    dep_id=DEP_ID.get_department_id()
    print(dep_id)



# class GETDEP_ID:
#     @classmethod
#     def get_dep_id(cls):
#         token=TOKENUTIL.get_token()
#         body={"name":"猪猪部门","code":"9999"}
#         resp=IHRMDEPARTMENT.department_add(token,body)
#         dep_id=resp.json().get("data").get("id")
#         return dep_id
#
#
# if __name__ == '__main__':
#     print(GETDEP_ID.get_dep_id())


